home *** CD-ROM | disk | FTP | other *** search
/ Amiga News 95 / Amiga News 95.iso / dpat / dpat19 / aps / test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-09  |  3.6 KB  |  112 lines

  1. ;/*
  2. lc -s -cciqstu -v -otest.o test.c
  3. blink lib:c.o test.o to test lib lib:aps.lib lib:lc.lib lib:amiga.lib nodebug
  4. quit
  5. ****************************************************************
  6. *
  7. *      Project:    APS: Application Preferences Server
  8. *      Function:   server test program
  9. *
  10. *      Created:    12/07/92    Jean-Michel Forgeas
  11. *
  12. *      Copyright © 1992 Jean-Michel Forgeas & Philippe Ducalet
  13. *                      All rights reserved
  14. *
  15. ****************************************************************/
  16.  
  17.  
  18. /****** Includes ************************************************/
  19.  
  20. #include <exec/types.h>
  21. #include <exec/memory.h>
  22. #include <dos/dos.h>
  23. #include <dos/dosextens.h>
  24.  
  25. #include <pragmas/exec_pragmas.h>
  26. #include <pragmas/dos_pragmas.h>
  27.  
  28. /* APS include files */
  29. #include "lci:aps.h"
  30. #include "lci:aps_protos.h"
  31.  
  32. extern ULONG DOSBase;
  33.  
  34.  
  35. /****** Imported ************************************************/
  36.  
  37.  
  38. /****** Exported ************************************************/
  39.  
  40.  
  41. /****** Statics *************************************************/
  42.  
  43. static struct MyPrefs1 {
  44.     ULONG data1;
  45.     ULONG data2;
  46.     ULONG data3;
  47.     ULONG data4;
  48.     } Defaults1 = { 1, 2 };
  49.  
  50. static struct MyPrefs2 {
  51.     UBYTE data1;
  52.     UBYTE data2;
  53.     UBYTE data3;
  54.     UBYTE data4;
  55.     } Defaults2 = { 10, 20 };
  56.  
  57.  
  58. /****************************************************************
  59.  *
  60.  *      Code
  61.  *
  62.  ****************************************************************/
  63.  
  64. void main()
  65. {
  66.   struct APSHandle *aps;
  67.   struct MyPrefs1 *myprefs1;
  68.   struct MyPrefs2 *myprefs2;
  69.   ULONG save, ioerror;
  70.  
  71.     if (aps = APS_RegisterAppl( "Test", NULL, NULL, NULL, NULL, NULL, NULL ))
  72.         {
  73.         if (myprefs1 = APS_OpenPrefs( aps, "ram:bbbprefs1", "prefs1",
  74.                         sizeof(struct MyPrefs1), MEMF_PUBLIC | MEMF_CLEAR,
  75.                         &Defaults1, 2*sizeof(ULONG) ))
  76.             {
  77.             if (myprefs2 = APS_OpenPrefs( aps, "ram:bbbprefs2", "prefs2",
  78.                             sizeof(struct MyPrefs2), MEMF_PUBLIC | MEMF_CLEAR,
  79.                             &Defaults2, 2*sizeof(UBYTE) ))
  80.  
  81.                 {
  82.                 printf( "oldprefs1: %ld %ld %ld %ld\n", myprefs1->data1, myprefs1->data2, myprefs1->data3, myprefs1->data4 );
  83.                 myprefs1->data2 = 10;
  84.                 myprefs1->data3 = 22;
  85.                 printf( "newprefs1: %ld %ld %ld %ld\n", myprefs1->data1, myprefs1->data2, myprefs1->data3, myprefs1->data4 );
  86.  
  87.                 printf( "oldprefs2: %ld %ld %ld %ld\n", myprefs2->data1, myprefs2->data2, myprefs2->data3, myprefs2->data4 );
  88.                 myprefs2->data2 = 100;
  89.                 myprefs2->data3 = 220;
  90.                 printf( "newprefs2: %ld %ld %ld %ld\n", myprefs2->data1, myprefs2->data2, myprefs2->data3, myprefs2->data4 );
  91.  
  92.                 save = APS_SavePrefs( aps, "ram:aaaprefs1", "ram:bbbprefs1", "prefs1", &ioerror );
  93.                 printf( "save=%ld, ioerror=%ld\n", save, ioerror );
  94.                 save = APS_SaveEnvPrefs( aps, "ram:bbbprefs1", "prefs1", &ioerror );
  95.                 printf( "save=%ld, ioerror=%ld\n", save, ioerror );
  96.  
  97.                 save = APS_SavePrefs( aps, "ram:aaaprefs2", "ram:bbbprefs2", "prefs2", &ioerror );
  98.                 printf( "save=%ld, ioerror=%ld\n", save, ioerror );
  99.                 save = APS_SaveEnvPrefs( aps, "ram:bbbprefs2", "prefs2", &ioerror );
  100.                 printf( "save=%ld, ioerror=%ld\n", save, ioerror );
  101.  
  102.                 APS_DeleteUserName( aps, "aaa" );
  103.  
  104.                 APS_ClosePrefs( aps, "prefs2" );
  105.                 }
  106.             APS_ClosePrefs( aps, "prefs1" );
  107.             }
  108.         APS_UnregisterAppl( aps );
  109.         }
  110.     else printf( "Cannot register...\n" );
  111. }
  112.